package com.xauto.pioneer.appuser.http;

import android.content.Context;
import android.util.Log;

import com.baidu.location.BDLocation;
import com.xauto.pioneer.appuser.R;
import com.xauto.pioneer.appuser.model.AccessToken;
import com.xauto.pioneer.appuser.model.ConfigVersion;
import com.xauto.pioneer.appuser.model.DamageImageInfo;
import com.xauto.pioneer.appuser.model.JSONStatus;
import com.xauto.pioneer.appuser.model.PageInfo;
import com.xauto.pioneer.appuser.util.MD5;
import com.xauto.pioneer.appuser.util.PackageUtil;
import com.xauto.pioneer.appuser.util.PreferencesUtils;
import com.xauto.pioneer.appuser.util.StringUtils;
import com.xauto.pioneer.appuser.util.TimeUtil;

import net.tsz.afinal.FinalDb;
import net.tsz.afinal.FinalHttp;
import net.tsz.afinal.http.AjaxCallBack;
import net.tsz.afinal.http.AjaxParams;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.List;

/**
 * Created by Lemon on 2015/12/10 22:26.
 * Desc:网络请求库
 */
public class LHttpLib implements LHttpInterface {

    private static final String TAG = "LHttpLib";
    private static String access_token = "";

    /** http请求接口前需判断access_token是否过期，如过期，需重新获取access_token，再请求接口*/
    private static void HttpPost(final Context context, final AjaxParams ajaxParams, final String route,
                                 final BaseLHttpHandler responseHandler) {
        access_token = PreferencesUtils.getString(context, Constants.KEY_ACCESS_TOKEN);
        if(isRefreshAccessToken(context)) {
            AjaxParams params = new AjaxParams();
            params.put("grant_type", Constants.token_grant_type);
            params.put("client_id", Constants.token_client_id);
            params.put("client_secret", Constants.token_client_secret);
            FinalHttp finalHttp = new FinalHttp();
            finalHttp.configTimeout(45000);// 超时时间
            finalHttp.post(API.server_get_token, params, new AjaxCallBack<String>() {
                @Override
                public void onSuccess(String s) {
                    super.onSuccess(s);
                    Log.e(Constants.RESULT,  "access_token" + "\n" + s);
                    if(!StringUtils.isBlank(s)) {
                        try {
                            AccessToken accessToken = new AccessToken().parse(new JSONObject(s));
                            access_token = accessToken.access_token;
                            PreferencesUtils.putString(context, Constants.KEY_ACCESS_TOKEN, access_token);
                            PreferencesUtils.putLong(context, Constants.KEY_EXPIRES_IN, accessToken.expires_in);
                            PreferencesUtils.putLong(context, Constants.KEY_ACCESS_TOKEN_TIME, System.currentTimeMillis());
                            HttpPost_(context, ajaxParams, route, responseHandler);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }

                @Override
                public void onFailure(Throwable t, int errorNo, String strMsg) {
                    super.onFailure(t, errorNo, strMsg);
                    t.fillInStackTrace();
                }
            });
        } else {
            HttpPost_(context, ajaxParams, route, responseHandler);
        }
    }

    /** http请求接口*/
    private static void HttpPost_(final Context context, AjaxParams ajaxParams, final String route,
                                         final BaseLHttpHandler responseHandler) {
/*context.getString(R.string.channel_20001)
* */
        ajaxParams.put("route", route);
        ajaxParams.put("token", PreferencesUtils.getString(context, Constants.KEY_TOKEN));
        ajaxParams.put("device_type", Constants.DEVICE_TYPE);
        ajaxParams.put("device_version", PackageUtil.getAppVersionName(context) + "");
        ajaxParams.put("version_code", PackageUtil.getAppVersionCode(context) + "");
        ajaxParams.put("channel", context.getString(R.string.channel_20001));//todo 修改渠道
        Log.e(Constants.REQUEST, API.server + "access_token=" + access_token + "\n" + ajaxParams.toString());

        FinalHttp finalHttp = new FinalHttp();
        finalHttp.configTimeout(45000);// 超时时间
//        finalHttp.configRequestExecutionRetryCount(3);
        finalHttp.addHeader("Content-Type", "application/x-www-form-urlencoded");
        finalHttp.post(API.server + "access_token=" + access_token, ajaxParams, new AjaxCallBack<String>() {
            @Override
            public void onStart() {
                super.onStart();
                if (responseHandler != null) {
                    responseHandler.onStarting();
                }
            }

            @Override
            public void onLoading(long count, long current) {
                super.onLoading(count, current);
                if (responseHandler != null) {
                    responseHandler.onLoading(count, current);
                }
            }

            @Override
            public void onSuccess(final String s) {
                super.onSuccess(s);
                if (responseHandler != null) {
                    if (!StringUtils.isBlank(s)) {
                        JSONStatus jsonStatus = BaseJSONData(s);
                        Log.e(Constants.RESULT, "   "+s);
                        if (jsonStatus.isSuccess) {
                            responseHandler.onSuccess(jsonStatus);
                        } else {
                            /*context.getResources().getString(R.string.request_error)
                            * R.string.request_error
                            * R.string.request_no_data
                            * R.string.request_no_data
                            * */
                            responseHandler.onFailure(
                                    new Throwable(
                                            "".equals(jsonStatus.error_description)?
                                                    "请求返回失败，请重试" : jsonStatus.error_description),
                                    jsonStatus.error_code,
                                    "".equals(jsonStatus.error_description) ?
                                            "请求返回失败，请重试" : jsonStatus.error_description);
                        }
                    } else {
                        responseHandler.onFailure(
                                new Throwable("请求返回无数据，请重试"),
                                404, "请求返回无数据，请重试");
                    }
                }
            }

            @Override
            public void onFailure(Throwable t, int errorNo, String strMsg) {
                super.onFailure(t, errorNo, strMsg);
                if (responseHandler != null) {
                    responseHandler.onFailure(t, errorNo, strMsg);
                    t.printStackTrace();
                }
            }
        });
    }

    /** 判断access_token是否已过期*/
    private static boolean isRefreshAccessToken(Context context) {
        String token = PreferencesUtils.getString(context, Constants.KEY_ACCESS_TOKEN);
        long token_time = PreferencesUtils.getLong(context, Constants.KEY_ACCESS_TOKEN_TIME);
        long expires_in = PreferencesUtils.getLong(context, Constants.KEY_EXPIRES_IN);
        if (token == null || StringUtils.isBlank(token) || StringUtils.isBlank(token_time + "")) {
            return true; //access_token不存在 ||  时间为空  - - - 需要刷新
        }
        if (System.currentTimeMillis() - token_time > expires_in * 1000) {
            return true; //（当前时间 － token_time ）> expires_in  - - - 需要刷新
        } else {
            return false; //access_token 正常  - - 不需要刷新-
        }
    }


    @Override
    public void getConfig(Context mContext, BaseLHttpHandler handler) {
        FinalDb finalDb = FinalDb.create(mContext);
        // TODO: 2017/6/1  ConfigVersion目前始终为空 未做存储处理
        List<ConfigVersion> configVersions = finalDb.findAll(ConfigVersion.class);
        ConfigVersion configVersion = null;
        if(configVersions != null && configVersions.size() > 0) {
            configVersion = configVersions.get(0);
        }else {
            configVersion = new ConfigVersion();
        }
        configVersion.setStart_date(TimeUtil.getFormatCurrentTime(TimeUtil.sdf3));
        configVersion.setEnd_date(TimeUtil.calculateTime(TimeUtil.sdf3,180));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("region", configVersion.region);
            jsonObject.put("bank", configVersion.bank);
            jsonObject.put("payment", configVersion.payment);
            jsonObject.put("billing_rules", configVersion.billing_rules);
            jsonObject.put("start_date", configVersion.start_date);
            jsonObject.put("end_date", configVersion.end_date);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CLIENT_CONFIG, handler);
    }

    /**
     * 获取验证码
     * @param mContext 上下文
     * @param mobile 手机号
     * @param handler callback
     */

    @Override
    public void getVerifyCode(Context mContext, String mobile, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("mobile", mobile);
            jsonObject.put("code", MD5.MD5Encode(mobile + Constants.SALT_KEY)); //MD5加密(手机号码+"salt_key")
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_VERIFY_CODE, handler);
    }

    /**
     * 快速登录\注册
     * @param mContext 上下文
     * @param mobile 手机号
     * @param code MD5加密("code"+"salt_key")
     * @param handler callback
     */
    @Override
    public void quickLogin(Context mContext, String mobile, String code, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("mobile", mobile);
            jsonObject.put("code", MD5.MD5Encode(code + Constants.SALT_KEY));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.QUICK_LOGIN, handler);
    }

    /**
     * 登出
     * @param mContext 上下文
     * @param member_id 会员id
     * @param mobile_token 设备推送号码
     * @param handler callback
     */
    @Override
    public void logout(Context mContext, String member_id, String mobile_token, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("mobile_token", mobile_token);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.LOGOUT, handler);
    }

    /**
     * 图片上传
     * @param mContext 上下文
     * @param member_id 会员id
     * @param image_type 图片类型(1-头像/2-身份证照/3-手持身份证照/4-驾照/…)
     * @param image
     * @param handler callback
     */
    @Override
    public void editImage(Context mContext, String member_id, String image_type, String image, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("image_type", image_type);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        AjaxParams ajaxParams = BaseAjaxParams(jsonObject);
        try {
            InputStream inputStream = new FileInputStream(image);
            ajaxParams.put("image", inputStream, image, "image/jpeg");
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        }
        HttpPost(mContext, ajaxParams, API.EDIT_IMAGE, handler);
    }

    /**
     * 获取用户信息
     * @param mContext 上下文
     * @param member_id 会员id
     * @param handler callback
     */
    @Override
    public void getMemberDetail(Context mContext, String member_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_MEMBER_DETAIL, handler);
    }

    /**
     * 编辑用户信息
     * @param mContext 上下文
     * @param member_id 会员id
     * @param type  1-头像; 2-身份证; 3-手持身份证; 4-驾照; 5-会员姓名; 6-手机号;
     * @param value 修改的参数值
     * @param code MD5加密("code"+"salt_key") *此状态只有在mobile时需要传入(type=2时)
     * @param handler callback
     */
    @Override
    public void editMemberInfo(Context mContext, String member_id, String type, String value, String code, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            if(type.equals(Constants.IMAGE_TYPE_AVATAR)) {
                jsonObject.put("icon_image", value);
            }
            if(type.equals(Constants.IMAGE_TYPE_ID_NUM)) {
                jsonObject.put("id_number_image", value);
            }
            if(type.equals(Constants.IMAGE_TYPE_HAND_ID)) {
                jsonObject.put("id_number_with_people_image", value);
            }
            if(type.equals(Constants.IMAGE_TYPE_DRIVER_ID)) {
                jsonObject.put("driving_license_image", value);
            }
            if(type.equals(Constants.EDIT_TYPE_MEMBER_NAME)) {
                jsonObject.put("member_name", value);
            }
            if(type.equals(Constants.EDIT_TYPE_MOBILE)) {
                jsonObject.put("mobile", value);
                jsonObject.put("code", MD5.MD5Encode(code + Constants.SALT_KEY));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.EDIT_MEMBER_INFO, handler);
    }

    /**
     * 编辑用户信息
     * @param mContext
     * @param member_id
     * @param idCardPath
     * @param idCardPath_back
     * @param idCardPath_Body
     * @param handler
     */
    @Override
    public void editMemberPcInfo(Context mContext, String member_id, String idCardPath, String idCardPath_back, String idCardPath_Body, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("id_number_image", idCardPath);
            jsonObject.put("id_number_image_back", idCardPath_back);
            jsonObject.put("id_number_with_people_image", idCardPath_Body);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.EDIT_MEMBER_INFO, handler);
    }

    /**
     * EDIT_MEMBER_INFO
     * @param mContext 上下文
     * @param member_id 会员id
     * @param value1  身份证
     * @param value2 半身照
     * @param code MD5加密("code"+"salt_key") *此状态只有在mobile时需要传入(type=2时)
     * @param handler callback
     */
    @Override
    public void submitIdentificationCardInfo(Context mContext, String member_id, String value1, String value2, String code, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
           // if (!StringUtils.isEmpty(value1))jsonObject.put("id_number_image", value1);
            if (!StringUtils.isEmpty(value2))jsonObject.put("driving_license_image", value2);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.EDIT_MEMBER_INFO, handler);
    }

    /**
     * 基本-获取地区列表
     * @param mContext 上下文
     * @param handler callback
     */
    @Override
    public void getRegionList(Context mContext, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_REGION_LIST, handler);
    }

    /**
     * 基本-获取银行列表
     * @param mContext 上下文
     * @param useType 使用类型(1-热门/2-全部)默认是1
     * @param handler callback
     */
    @Override
    public void getBankList(Context mContext,String useType,BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("use_type", useType);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_BANK_LIST, handler);
    }

    /**
     * 会员-校验会员信息
     * @param mContext 上下文
     * @param validate_type 校验类型(1-手机号码/2-邮箱)
     * @param validate_value 需要校验是否存在的值
     * @param handler callback
     */
    @Override
    public void validateMemberInfo(Context mContext, String validate_type, String validate_value, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("validate_type", validate_type);
            jsonObject.put("validate_value", validate_value);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.VALIDATE_MEMBER_INFO, handler);
    }

    /**
     * 基本-通过坐标获取城市ID
     * @param mContext 上下文
     * @param longitude_num 经度
     * @param latitude_num 纬度
     * @param handler callback
     */
    @Override
    public void getRegionCoordinate(Context mContext, String longitude_num, String latitude_num, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("longitude_num", longitude_num);
            jsonObject.put("latitude_num", latitude_num);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_REGION_COORDINATE, handler);
    }

    /**
     * 获取闪屏广告
     * @param mContext 上下文
     * @param handler callback
     */
    @Override
    public void getIndexBanner(Context mContext, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_INDEX_BANNER, handler);
    }

    /**
     * 获取取车网点列表
     * @param memberid
     * @param mContext 上下文
     * @param longitude_num
     * @param latitude_num
     * @param distance_range
     * @param pageInfo
     * @param handler callback
     */
    @Override
    public void getPickParkingSiteList(String memberid,Context mContext, String longitude_num, String latitude_num,
                                       String distance_range, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",memberid);
            jsonObject.put("longitude_num",StringUtils.isEmpty(StringUtils.getSingleDouble(longitude_num)) ? longitude_num : StringUtils.getSingleDouble(longitude_num));
            jsonObject.put("latitude_num",StringUtils.isEmpty(StringUtils.getSingleDouble(latitude_num)) ? latitude_num : StringUtils.getSingleDouble(latitude_num));
            if (!StringUtils.isEmpty(distance_range))jsonObject.put("distance_range", distance_range);
            if (pageInfo != null)jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_PICK_PARKING_SITE_LIST, handler);
    }

    /**
     * 获取取车网点车辆列表
     * @param mContext 上下文
     * @param parking_site_id 网点ID
     * @param pageInfo
     * @param handler callback
     */
    @Override
    public void getParkingSiteCarList(Context mContext, String parking_site_id,PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("parking_site_id", parking_site_id);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_PARKING_SITE_CAR_LIST, handler);
    }

    /**
     * 获取web数据信息
     * @param mContext 上下文
     * @param request_type 请求类型
     * @param member_id
     * @param car_order_no
     * @param car_no
     * @param handler callback
     */
    @Override
    public void getWebInfo(Context mContext, String request_type, String  member_id, String car_order_no,String car_no, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        JSONObject extObject = new JSONObject();
        try {
            jsonObject.put("request_type", request_type);
            extObject.put("member_id",member_id);
            extObject.put("car_order_no",car_order_no);
            extObject.put("car_no",car_no);
            jsonObject.put("ext_data", extObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_WEB_DATA_INFO, handler);
    }

    /**
     * 提交意见反馈
     * @param mContext
     * @param member_id
     * @param feedback_text
     * @param handler
     */
    @Override
    public void getFeedback(Context mContext, String member_id, String feedback_text, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("feedback_text", feedback_text);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_FEEDBACK, handler);
    }

    /**
     * 保证金-提交保证金
     * @param mContext
     * @param member_id 会员id
     * @param Num
     * @param payment_code 支付方式CODE
     * @param handler
     */
    @Override
    public void submitDeposit(Context mContext, String member_id,String Num, String payment_code, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            JSONObject paymentCodeJson = new JSONObject();
            paymentCodeJson.put("payment_code", payment_code);
            paymentCodeJson.put("total", Num);
            jsonObject.put("order_info", paymentCodeJson);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.SUBMIT_DEPOSIT, handler);
    }

    /**
     * 订单-开启车辆订单
     * @param mContext
     * @param member_id 会员id
     * @param car_no 车辆编号
     * @param handler
     */
    @Override
    public void startCarOrder(Context mContext, String member_id, String car_no, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_no", car_no);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.START_CAR_ORDER, handler);
    }

    /**
     * 订单-获取车辆订单详情
     * @param mContext
     * @param member_id 会员id
     * @param car_order_no 车辆订单编号
     * @param handler
     */
    @Override
    public void getCarOrderDetail(Context mContext, String member_id, String car_order_no, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_ORDER_DETAIL, handler);
    }

    /**
     * 获取车辆损伤列表
     * @param mContext
     * @param member_id 会员id
     * @param car_no 车辆编号
     * @param handler
     */
    @Override
    public void getCarDamageList(Context mContext, String member_id, String car_no, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_no", car_no);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_DAMAGE_LIST, handler);
    }

    /**
     * 获取车辆计费规则
     * @param mContext
     * @param handler
     */
    @Override
    public void getCarBillingRulesList(Context mContext, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_BILLING_RULES_LIST, handler);
    }

    /**
     *
     * @param mContext
     * @param member_id
     * @param car_order_no
     * @param operator_type 操作类型(1-开始用车/2-取消订单/3-编辑订单)
     * @param imageInfos car_order_damage_image_list	damage_image	损伤图片
                                                            damage_date	时间unix_time
                                                            damage_address	拍摄地址
                                                            damage_latitude	拍摄经度(百度)
                                                            damage_longitude	拍摄维度(百度)
     * @param handler
     */
    @Override
    public void operatorCarOrder(Context mContext, String member_id, String car_order_no, String operator_type, List<DamageImageInfo> imageInfos, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("operator_type", operator_type);
            JSONObject car_order_info = new JSONObject();
            JSONArray imageArray = new JSONArray();
            if (imageInfos != null && imageInfos.size() > 0){
                for (int i=0,size = imageInfos.size();i<size;i++){
                    DamageImageInfo damageImageInfo = imageInfos.get(i);
                    JSONObject item = new JSONObject();
                    item.put("damage_image",damageImageInfo.damage_image);
                    item.put("damage_date",damageImageInfo.damage_date);
                    item.put("damage_address",damageImageInfo.damage_address);
                    item.put("damage_latitude",damageImageInfo.damage_latitude);
                    item.put("damage_longitude",damageImageInfo.damage_longitude);
                    imageArray.put(item);
                }
            }
            car_order_info.put("car_order_damage_image_list",imageArray);
            jsonObject.put("car_order_info", car_order_info);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.OPERATOR_CAR_ORDER, handler);
    }

    /**
     * 就近取车
     * @param mContext
     * @param member_id
     * @param car_order_no
     * @param member_latitude
     * @param member_longitude
     * @param handler
     */
    @Override
    public void getMemberToCar(Context mContext, String member_id, String car_order_no,String member_latitude,String member_longitude, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("member_latitude", member_latitude);
            jsonObject.put("member_longitude",member_longitude);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_MEMBER_TO_CAR, handler);
    }

    /**
     * 操作车辆
     * @param mContext
     * @param bdLocation
     * @param member_id
     * @param car_order_no
     * @param operator_type 操作类型(1-打开车门/2-锁闭车辆/3-鸣笛找车)
     * @param handler
     */
    @Override
    public void operatorCar(Context mContext, BDLocation bdLocation, String member_id, String car_order_no, String operator_type, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("operator_type", operator_type);
            jsonObject.put("member_latitude", String.valueOf(bdLocation.getLatitude()));
            jsonObject.put("member_longitude",  String.valueOf(bdLocation.getLongitude()));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.OPERATOR_CAR, handler);
    }

    /**
     * 获取还车网点列表
     * @param mContext
     * @param member_id
     * @param car_order_no
     * @param longitude_num
     * @param latitude_num
     * @param distance_range
     * @param pageInfo
     * @param handler
     */
    @Override
    public void getReturnParkingSiteList(Context mContext, String member_id, String car_order_no, String longitude_num, String latitude_num, String distance_range, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("longitude_num", longitude_num);
            jsonObject.put("latitude_num", latitude_num);
            jsonObject.put("distance_range", distance_range);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_RETURN_PARKING_SITE_LIST, handler);
    }

    /**
     * 获取网点车位列表
     * @param mContext
     * @param member_id
     * @param car_order_no
     * @param parking_site_no
     * @param pageInfo
     * @param handler
     */
    @Override
    public void getParkingSpaceList(Context mContext, String member_id, String car_order_no, String parking_site_no, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("parking_site_no", parking_site_no);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_PARKING_SPACE_LIST, handler);
    }

    /**
     *订单-申请还车
     * @param mContext
     * @param member_id
     * @param car_order_no
     * @param car_order_info    parking_site_no	网点编号
                                parking_space_no	停车位编号
                                car_order_return_image	还车图片
     * @param handler
     */
    @Override
    public void applyReturnCar(Context mContext, String member_id, String car_order_no, JSONObject car_order_info, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("car_order_info", car_order_info);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.APPLY_RETURN_CAR, handler);
    }

    /**
     * 检查车辆网点信息
     * @param mContext
     * @param member_id
     * @param car_order_no
     * @param parking_site_no
     * @param longitude_num
     * @param latitude_num
     * @param handler
     */
    @Override
    public void checkParkingSite(Context mContext, String member_id, String car_order_no, String parking_site_no, String longitude_num, String latitude_num, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            if (StringUtils.isEmpty(longitude_num))return;
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("parking_site_no", parking_site_no);
            jsonObject.put("longitude_num", longitude_num);
            jsonObject.put("latitude_num", latitude_num);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.CHECK_PARKING_SITE, handler);
    }
/**申请还车第一步*/
@Override
public void returnCar(Context mContext, String car_order_no,String member_id, String parking_site_no, String longitude_num, String latitude_num, BaseLHttpHandler handler) {
    JSONObject jsonObject = new JSONObject();
    try {
        if (StringUtils.isEmpty(longitude_num))return;
        jsonObject.put("car_order_no", car_order_no);
        jsonObject.put("member_id", member_id);
        jsonObject.put("parking_site_no", parking_site_no);
        jsonObject.put("car_longitude", longitude_num);
        jsonObject.put("car_latitude", latitude_num);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    HttpPost(mContext, BaseAjaxParams(jsonObject), API.RETURN_CAR_ONE, handler);
}

    /**
     * 提交加油信息
     * @param mContext
     * @param member_id
     * @param car_order_no
     * @param car_refuel_info
     * @param handler
     */
    @Override
    public void submitCarRefuel(Context mContext, String member_id, String car_order_no, JSONObject car_refuel_info, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("car_refuel_info", car_refuel_info);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.SUBMIT_CAR_REFUEL, handler);
    }

    /**
     * 获取会员订单列表
     * @param mContext
     * @param member_id
     * @param pageInfo
     * @param handler
     */
    @Override
    public void getCarOrderList(Context mContext, String member_id, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_ORDER_LIST, handler);
    }

    /**
     * 获取会员订单详情
     * @param mContext
     * @param member_id
     * @param car_order_no
     * @param handler
     */
    @Override
    public void getCarOrderDetailInfo(Context mContext, String member_id, String car_order_no, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_ORDER_DETAIL_INFO, handler);
    }

    /**
     *
     * @param mContext
     * @param member_id
     * @param voucher_type 优惠券类型(1-未使用/2-已使用/0-全部)
     * @param car_order_no
     * @param pageInfo
     * @param handler
     * @param Route
     */
    @Override
    public void getVoucherList(Context mContext, String member_id, String voucher_type, String car_order_no,PageInfo pageInfo, BaseLHttpHandler handler,String Route) {
        JSONObject jsonObject = new JSONObject();
        JSONObject filterJsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            filterJsonObject.put("voucher_type",voucher_type);
            filterJsonObject.put("car_order_no",car_order_no);
            jsonObject.put("filter_info", filterJsonObject);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject),Route, handler);
    }

    /**
     * 保证金-获取会员保证金消费列表
     * @param mContext
     * @param member_id
     * @param pageInfo
     * @param handler
     */
    @Override
    public void getDepositTransactionList(Context mContext, String member_id, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_DEPOSIT_TRANS_LIST, handler);
    }

    /**
     * 账户-获取会员账户消费列表
     * @param mContext
     * @param member_id
     * @param pageInfo
     * @param handler
     */
    @Override
    public void getTransacitonList(Context mContext, String member_id, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_TRANS_LIST, handler);
    }

    /**
     * 保证金-保证金提现
     * @param mContext
     * @param member_id
     * @param transaction_amount
     * @param member_account_id
     * @param bank_id
     * @param bank_account_name
     * @param bank_account_number
     * @param handler
     */
    @Override
    public void submitTransaction(Context mContext, String member_id, String transaction_amount, String member_account_id, String bank_id,String bank_account_name, String bank_account_number, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        JSONObject transJsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            transJsonObject.put("transaction_amount",transaction_amount);
            transJsonObject.put("member_account_id",member_account_id);
            transJsonObject.put("bank_id",bank_id);
            transJsonObject.put("bank_account_name",bank_account_name);
            transJsonObject.put("bank_account_number",bank_account_number);
            jsonObject.put("transaction_info", transJsonObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.SUBMIT_TRANSACTION, handler);
    }

    /**
     * 用户信息认证-银行卡
     * @param mContext
     * @param userName
     * @param member_id
     * @param bank_id
     * @param bank_account_name
     * @param bank_account_number
     * @param IdNumber
     * @param handler
     */
    @Override
    public void TakeCar_submitTransaction(Context mContext,String userName,String member_id, String bank_id,String bank_account_name, String bank_account_number,String IdNumber, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("bank_id",bank_id);
            jsonObject.put("bank_name",bank_account_name);
            jsonObject.put("bank_account_number",bank_account_number);
            jsonObject.put("bank_account_name",userName);
            jsonObject.put("id_number",IdNumber);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.MEMBER_CARD, handler);
    }

    @Override
    public void submitAmountTransaction(Context mContext, String member_id, String transaction_amount, String member_account_id,String bank_id, String bank_account_name, String bank_account_number, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        JSONObject transJsonObject = new JSONObject();
        try {
            // TODO: 2017/8/8
            jsonObject.put("member_id",member_id);
            transJsonObject.put("transaction_amount",transaction_amount);
            transJsonObject.put("member_account_id",member_account_id);
            transJsonObject.put("bank_id",bank_id);
            transJsonObject.put("bank_account_name",bank_account_name);
            transJsonObject.put("bank_account_number",bank_account_number);
            jsonObject.put("transaction_info", transJsonObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.SUBMIT_AMOUNT_TRANSACTION, handler);
    }

    @Override
    public void getMemberAccountInfo(Context mContext, String member_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_MEMBER_ACCOUNT_INFO, handler);
    }

    @Override
    public void getShareInfo(Context mContext, String share_type, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("share_type",share_type);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_SHARE_INFO, handler);
    }

    @Override
    public void addBalanceOrder(Context mContext, String member_id, String balance_amount, String payment_code, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        JSONObject order_info = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            order_info.put("balance_amount",balance_amount);
            order_info.put("payment_code",payment_code);
            jsonObject.put("order_info",order_info);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.ADD_BALANCE_ORDER, handler);
    }

    @Override
    public void submitBalanceOrder(Context mContext, String member_id, String balance_order_no, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("balance_order_no",balance_order_no);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.SUBMIT_BALANCE_ORDER, handler);
    }

    @Override
    public void getBalanceOrderDetail(Context mContext, String member_id, String balance_order_no, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("balance_order_no",balance_order_no);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_BALANCE_ORDER_DETAIL, handler);
    }

    @Override
    public void getSettingDateList(Context mContext, String start_date, String end_date, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("start_date",start_date);
            jsonObject.put("end_date",end_date);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_SETTING_DATE_LIST, handler);
    }

    @Override
    public void checkoutOrder(Context mContext, String member_id, String car_order_no, String payment_code, String voucher_member_id, String is_use_balance_amount, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        JSONObject checkJsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("car_order_no",car_order_no);
            checkJsonObject.put("payment_code",payment_code);
            checkJsonObject.put("voucher_member_id",voucher_member_id);
            checkJsonObject.put("is_use_balance_amount",is_use_balance_amount);
            jsonObject.put("check_out_info",checkJsonObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.ORDER_CHECK_OUT, handler);
    }

    @Override
    public void submitCarOrder(Context mContext, String member_id, String car_order_no, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("car_order_no",car_order_no);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.SUBMIT_CAR_ORDER, handler);
    }

    @Override
    public void editPushDevice(Context mContext, String member_id, String mobile_token, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("mobile_token",mobile_token);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.EDIT_PUSH_DEVICE, handler);
    }

    @Override
    public void loginWithToken(Context mContext, String member_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.LOGIN_WITH_TOKEN, handler);
    }

    @Override
    public void getMessageList(Context mContext, String member_id, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_MESSAGE_LIST, handler);
    }

    @Override
    public void getMessageDetail(Context mContext, String member_id, String message_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("message_id",message_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_MESSAGE_DETAIL, handler);
    }

    @Override
    public void getDepositDetail(Context mContext, String member_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_DEPOSIT_DETAIL, handler);
    }

    @Override
    public void getReturnParkingSiteDetail(Context mContext, String member_id, String car_order_no, double longitude_num, double latitude_num, String parking_site_no, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("car_order_no",car_order_no);
            jsonObject.put("longitude_num",longitude_num);
            jsonObject.put("latitude_num",latitude_num);
            jsonObject.put("parking_site_no",parking_site_no);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_RETURN_SITE_DETAIL, handler);
    }

    @Override
    public void getGuideCategoryList(Context mContext, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_GUIDE_CATEGORY_LIST, handler);
    }

    @Override
    public void getGuideList(Context mContext, String guide_category_id, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("guide_category_id",guide_category_id);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_GUIDE_LIST, handler);
    }

    @Override
    public void getGuideDetail(Context mContext, String guide_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("guide_id",guide_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_GUIDE_DETAIL, handler);
    }

    @Override
    public void getCarRefuelList(Context mContext, String member_id, String car_order_no, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_REFUEL_LIST, handler);
    }
    /**
     * 添加订单附加信息
     * */
    @Override
    public void getCarOrderOtherList(Context mContext, String member_id, String car_order_no, PageInfo pageInfo, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_OTHER_LIST, handler);
    }
    @Override
    public void getCarRefuelDetail(Context mContext, String member_id, String car_refuel_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_refuel_id", car_refuel_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_REFUEL_DETAIL, handler);
    }
    @Override
    public void getCarOrderOtherDetail(Context mContext, String member_id, String additional_order_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("additional_order_id", additional_order_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_ORDER_OTHER_DETAIL, handler);
    }
    @Override
    public void getDeviceNotifyInfo(Context mContext, String member_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_DEVICE_NOTIFY_INFO, handler);
    }
    @Override
    public void getMemberMessageList(Context mContext, String member_id,String message_status , PageInfo pageInfo,BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("message_status", message_status);
            jsonObject.put("pagination", pageInfo.getPageInfo(pageInfo.page, pageInfo.count));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_MEMBER_MESSAGE_LIST, handler);
    }
    @Override
    public void getOrderFeedbackInfo(Context mContext, String member_id,String car_order_no ,Object car_object,BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("car_order_feedback_info", car_object);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_FEEDBACK, handler);
    }
    @Override
    public void getPreReturnCar(Context mContext, String member_id,String car_order_no ,JSONArray arry,BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("car_order_rental_images", arry);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CAR_PC, handler);
    }
    @Override
    public void getMemberMessageDateil(Context mContext, String member_id,String member_message_id,BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("member_message_id", member_message_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_MESSAGE_DETAIL, handler);
    }
    /**
     * 重新进行结算
     */
    @Override
    public void OrderCostAgain(Context mContext, String member_id, String car_order_no, JSONObject car_order_info, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("car_order_no", car_order_no);
            jsonObject.put("car_order_info", car_order_info);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.ORDER_COST_AGAIN, handler);
    }
    /**
     * 提交用户发票信息
     */
    @Override
    public void SetReceiptInfo(Context mContext, String member_id, String receipt_name, String receipt_bank,
                               String receipt_address, String receipt_phone, String receipt_type, String receipt_num, String receipt_message,String receipt_mailaddr,
                               BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("receipt_name", receipt_name);
            jsonObject.put("receipt_bank", receipt_bank);
            jsonObject.put("receipt_address", receipt_address);
            jsonObject.put("receipt_phone", receipt_phone);
            jsonObject.put("receipt_type", receipt_type);
            jsonObject.put("receipt_num", receipt_num);
            jsonObject.put("receipt_message", receipt_message);
            jsonObject.put("receipt_mailaddr", receipt_mailaddr);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.SET_RECEIPT_INFO, handler);
    }
    /**
     * 获取用户发票信息
     */
    @Override
    public void getReceiptInfo(Context mContext, String member_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_RECEIPT_INFO, handler);
    }
    /**
     * 获取用车可开票订单列表
     */
    @Override
    public void getCarReceiptableList(Context mContext,String member_id,BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_CARRECEIPTABLE_LIST, handler);
    }

    /**
     * 获取用户可开票总和
     */
    @Override
    public void getReceiptsCount(Context mContext, String member_id,JSONArray receiptIds, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("Count_ID",receiptIds);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_USERRECEIPT_COUNT, handler);
    }
    /**
     * 提交开票申请
     */
    @Override
    public void submitApplyReceipt(Context mContext, String member_id, JSONArray receiptIds, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("Count_ID",receiptIds);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.SUBMIT_APPLYRECEIPT, handler);
    }

    @Override
    public void submitReceiptOrder(Context mContext, String member_id, String receipt_order_id, String payment_code, String is_use_balance_amount, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        JSONObject checkJsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("receipt_order_id",receipt_order_id);
            checkJsonObject.put("payment_code",payment_code);
            checkJsonObject.put("is_use_balance_amount",is_use_balance_amount);
            jsonObject.put("check_out_info",checkJsonObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.SUBMIT_RECEIPTORDER, handler);
    }

    @Override
    public void getInvoicedList(Context mContext, String member_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_INVOICEDLIST, handler);
    }

    @Override
    public void checkoutForReceipt(Context mContext, String member_id, String payment_code, String is_use_balance_amount, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        JSONObject checkJsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            checkJsonObject.put("payment_code",payment_code);
            checkJsonObject.put("is_use_balance_amount",is_use_balance_amount);
            jsonObject.put("check_out_info",checkJsonObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.CHECKOUT_FORRECEIPT, handler);
    }

    /**
     * 获取用户可开票总和
     */
    @Override
    public void getMonthlyrentSiteList(Context mContext, String member_id,BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_MONTHLY_RENT_SITELIST, handler);
    }

    /**
     *
     * 获取包月停车场计费规则
     * @param mContext
     * @param member_id
     * @param parking_id
     * @param handler
     */
    @Override
    public void getMonthlyrentRule(Context mContext, String member_id, String parking_id, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("parking_id",parking_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.GET_MONTHLY_RENT_RULE, handler);
    }
    /**
     * 71  创建包月停车场订单
     * @param mContext
     * @param member_id
     * @param parking_rule_id
     * @param car_no
     * @param handler
     */
    @Override
    public void createParkingrentOrder(Context mContext, String member_id, String parking_rule_id,String parking_id,String car_no, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("parking_rule_id",parking_rule_id);
            jsonObject.put("parking_id",parking_id);
            jsonObject.put("car_no",car_no);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.PARKINGRENT_CREATEORDER, handler);
    }
    /**
     * 72   提交包月停车场订单
     * @param mContext
     * @param member_id
     * @param parking_order_id
     * @param payment_code
     * @param is_use_balance_amount
     * @param handler
     */
    @Override
    public void submitParkingrentOrder(Context mContext, String member_id, String parking_order_id, String payment_code, String is_use_balance_amount, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        JSONObject checkJsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("parking_order_id",parking_order_id);
            checkJsonObject.put("payment_code",payment_code);
            checkJsonObject.put("is_use_balance_amount",is_use_balance_amount);
            jsonObject.put("check_out_info",checkJsonObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.PARKINGRENT_SUBMITORDER, handler);
    }

    /**
     * 73 包月支付选择方式
     * @param mContext
     * @param member_id
     * @param parking_order_id
     * @param payment_code
     * @param is_use_balance_amount
     * @param handler
     */
    @Override
    public void checkoutParkingrentOrder(Context mContext, String member_id, String parking_order_id, String payment_code, String is_use_balance_amount, BaseLHttpHandler handler) {
        JSONObject jsonObject = new JSONObject();
        JSONObject checkJsonObject = new JSONObject();
        try {
            jsonObject.put("member_id",member_id);
            jsonObject.put("parking_order_id",parking_order_id);
            checkJsonObject.put("payment_code",payment_code);
            checkJsonObject.put("is_use_balance_amount",is_use_balance_amount);
            jsonObject.put("check_out_info",checkJsonObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        HttpPost(mContext, BaseAjaxParams(jsonObject), API.CHECKOUT_FORPARKINGRENT, handler);
    }

    /**
     * 封装返回数据
     * @param t 返回数据字符串
     * @return JSONStatus对象
     */
    private static JSONStatus BaseJSONData(String t) {
        JSONStatus jsonStatus = new JSONStatus();
        try {
            JSONObject obj = new JSONObject(t);
            if (obj.length() > 0) {
                jsonStatus = new JSONStatus().parse(obj);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return jsonStatus;
    }

    /** 封装请求参数*/
    private static AjaxParams BaseAjaxParams(JSONObject jsonObject) {
        AjaxParams ajaxParams = new AjaxParams();
        ajaxParams.put("jsonText", jsonObject.toString());
        return ajaxParams;
    }
}
